package com.onion.utils.utils;

import org.apache.commons.lang3.StringUtils;

public class Asserts {

    /**
     * 不能为Null
     * @param val
     * @param name
     */
    public static void notNull(Object val, String name) {
        if (val == null) {
            throw new IllegalStateException(name + " is null");
        }
    }

    /**
     * 不能为空和空串
     * @param s
     * @param name
     */
    public static void notEmpty(CharSequence s, String name) {
        if (StringUtils.isEmpty(s)) {
            throw new IllegalStateException(name + " is empty");
        }
    }

    /**
     * 不能为空、空串和空格
     * @param s
     * @param name
     */
    public static void notBlank(CharSequence s, String name) {
        if (StringUtils.isBlank(s)) {
            throw new IllegalStateException(name + " is blank");
        }
    }

}